﻿// Copyright (C) 2014 Can Batu Erdem
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

using Cyrene.Strategy;
using System;
using System.Collections.Specialized;
using System.Globalization;

namespace Cyrene.Serializer
{
    internal static class SystemSerializer
    {
        internal static string Serialize(TableGeneratorStrategy tableGenerator)
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("Date", DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss K"));
            collection.Add("64Bit OS", Environment.Is64BitOperatingSystem.ToString());
            collection.Add("64Bit Process", Environment.Is64BitProcess.ToString());
            collection.Add("Processor Count", Environment.ProcessorCount.ToString(CultureInfo.InvariantCulture));
            collection.Add("Working Set", (Environment.WorkingSet / (1024 * 1024)).ToString(CultureInfo.InvariantCulture) + " MB");
            collection.Add("System Page Size", Environment.SystemPageSize.ToString(CultureInfo.InvariantCulture));
            collection.Add("UserDomainName", Environment.UserDomainName);
            collection.Add("UserName", Environment.UserName);
            return tableGenerator.Generate("System", collection);
        }
    }
}
